package com.testyourshell.service.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.testyourshell.dao.user.UserDAO;
import com.testyourshell.exception.user.UserNotFoundException;
import com.testyourshell.model.user.User;
import com.testyourshell.service.BaseServiceImpl;

@Service
public class UserServiceImpl extends BaseServiceImpl<User, UserDAO> implements
		UserService {

	@Autowired
	private UserDAO userDAO;

	@Transactional
	@Override
	public User findByUsername(String username) throws UserNotFoundException {
		User user = userDAO.findByUsername(username);

		if (user == null)
			throw new UserNotFoundException();

		return user;
	}
}
